import { stringify } from 'qs';
import request from '@/utils/request';


/**
 * 查询全部的课程
 * @param {*} params 
 */
export async function queryLesson(params) {
  return request('/courseBasic/list', {
    method: 'POST',
    data: {
      ...params
    },
  });
}

/**
 * 查询课程详情
 * @param {*} params 
 */
export async function fetchLesson(params) {
  return request(`/courseBasic/courseBasicInfo?${stringify(params)}`);
}


/**
 * 删除课程
 * @param {*} params 
 */
export async function removeLesson(params) {
  return request(`/courseBasic/delete?${stringify(params)}`);
}

/**
 * 批量删除课程
 * @param {*} params 
 */
export async function batchRemoveLesson(params) {
  return request(`/courseBasic/deleteBatch?${stringify(params, { arrayFormat: 'brackets' })}`);
}


/**
 * 新增课程
 * @param {*} params 
 */
export async function addLesson(params) {
  return request('/courseBasic/save', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 更新会员
 * @param {*} params 
 */
export async function updateLesson(params) {
  return request('/courseBasic/update', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 根据当前登录人查询教练List
 * @param {*} params 
 */
export async function fetchCoach(params) {
  return request('/sys/user/queryCoachAndSale', {
    method: 'POST',
    data: {
      ...params
    },
  });
}

/**
 * 上传
 * @param {*} params 
 */
export async function upload(params) {
  return request('/commonInfo/uploadFile', {
    method: 'POST',
    data: params,
  });
}

/**
 * 根据课程id查询会员卡信息详情列表
 * @param {*} params 
 */
export async function queryMemberCardInfoByCourseId(params) {
  const formData = new FormData();
  formData.append('courseId',params.courseId);
  return request('/memberCardController/queryMemberCardInfoByCourseId', {
    method: 'POST',
    data: formData,
  });
}


/**
 * 根据用户信息查询场馆List
 * @param {*} params 
 */
export async function fetchShopList(params) {
  return request('/venueInfo/queryVenueInfoListByUserId', {
    method: 'POST',
    requestType:'form',
    data: { ...params },
  });
}

/**
 * 根据课表id查询支持会员卡
 * @param {*} params 
 */
export async function queryAllCardByCourseId(params) {
  return request('/classTableInfo/queryAllCardByCourseId', {
    method: 'POST',
    requestType:'form',
    data: {
      ...params
    },
  });
}

/**
 * 根据课表id，添加支持会员卡
 * @param {*} params 
 */
export async function saveSetCardByCourseId(params) {
  return request('/classTableInfo/saveSetCardByCourseId', {
    method: 'POST',
    data: params,
  });
}



/**
 * 查询所有课程基本信息列表
 * @param {*} params 
 */
export async function selectAllCourse(params) {
  return request('/courseBasic/selectAll', {
    method: 'POST',
    requestType:'form',
    data: {
      ...params
    },
  });
}